define(function(require, exports, module) {
    'use strict';
    var rk = require('rk');
    var userService = {};
    userService.appsTypeConstants = { //app类型对应的模版
        1: {
            tpl: "Notice_Follow", // /tpl_Notice_Follow.tpl
            defaultUrl: ""
        }, //关注
        2: {
            tpl: "Notice_Announcement", // /tpl_Notice_Announcement.tpl
            defaultUrl: ""
        }, //公告
        3: {
            tpl: "Notice_Colleagues_Message", // /tpl_Notice_Colleagues_Message.tpl
            defaultUrl: ""
        }, //同事留言
        4: {
            tpl: "Notice_Apps_Message", // /tpl_Notice_Apps_Message.tpl
            defaultUrl: ""
        }, //其他留言
        5: {
            tpl: "Notice_Colleagues_Message_Reply", // /tpl_Notice_Colleagues_Message_Reply.tpl
            defaultUrl: ""
        }, //同事留言回复
        6: {
            tpl: "Notice_Invite", // /tpl_Notice_Invite.tpl
            defaultUrl: ""
        }, //邀请外部员工
        7: {
            tpl: "Notice_Inner_Invite", // /tpl_Notice_Inner_Invite.tpl
            defaultUrl: ""
        }, //邀请内部员工
        /*8: {
            tpl: "Notice_Task_Add", // /tpl_Notice_Task_Add.tpl
            defaultUrl: ""
        }, //任务分配 废弃*/
        9: {
            tpl: "Notice_ActivityStream_Delete", // /tpl_Notice_ActivityStream_Delete.tpl
            defaultUrl: ""
        }, //删除
        10: {
            tpl: "Notice_Work_Report", // /tpl_Notice_Work_Report.tpl
            defaultUrl: ""
        }, //工作报告
        11: {
            tpl: "Notice_Apply", // /tpl_Notice_Apply.tpl
            defaultUrl: ""
        }, //审批提醒
        12: {
            tpl: "Notice_Product_Question", // /tpl_Notice_Product_Question.tpl
            defaultUrl: ""
        }, //产品/产品线页面的提问
        13: {
            tpl: "Notice_Contract_Create", // /tpl_Notice_Contract_Create.tpl
            defaultUrl: ""
        }, //合同创建
        14: {
            tpl: "Notice_Payment", // /tpl_Notice_Payment.tpl
            defaultUrl: ""
        }, //创建还款记录
        15: {
            tpl: "Notice_Payment_Plan", // /tpl_Notice_Payment_Plan.tpl
            defaultUrl: ""
        }, //创建还款计划
        16: {
            tpl: "Notice_Recycle_Account", // /tpl_Notice_Recycle_Account.tpl
            defaultUrl: ""
        }, //回收客户
        17: {
            tpl: "Notice_Expire_Account", // /tpl_Notice_Expire_Account.tpl
            defaultUrl: ""
        }, //客户过期
        18: {
            tpl: "Notice_Assign_Account", // /tpl_Notice_Assign_Account.tpl
            defaultUrl: ""
        }, //指派客户
        19: {
            tpl: "Notice_Closing_Contract", // /tpl_Notice_Closing_Contract.tpl
            defaultUrl: ""
        }, //合同到期提醒
        20: {
            tpl: "Notice_High_Sea_New_Import_Account", // /tpl_Notice_High_Sea_New_Import_Account.tpl
            defaultUrl: ""
        }, //导入客户到公海池
        22: {
            tpl: "Notice_Task_Update", // /tpl_Notice_Task_Update.tpl
            defaultUrl: ""
        }, //任务更新
        23: {
            tpl: "Notice_Import_Result", // /tpl_Notice_Import_Result.tpl
            defaultUrl: ""
        }, //数据导入结果
        24: {
            tpl: "Notice_Shift", // /tpl_Notice_Shift.tpl
            defaultUrl: ""
        }, //转移：线索、客户、机会、个案等
        25: {
            tpl: "Notice_Assign_Lead", // /tpl_Notice_Assign_Lead.tpl
            defaultUrl: ""
        }, //线索池分配线索发通知
        26: {
            tpl: "Notice_Recycle_Lead", // /tpl_Notice_Recycle_Lead.tpl
            defaultUrl: ""
        }, //线索池回收线索发通知
        27: {
            tpl: "Notice_Expire_Lead", // /tpl_Notice_Expire_Lead.tpl
            defaultUrl: ""
        }, //线索过期
        28: {
            tpl: "Notice_Forward_Message", // /tpl_Notice_Forward_Message.tpl
            defaultUrl: ""
        }, //转发消息
        29: {
            tpl: "Notice_File_Delete", // /tpl_Notice_File_Delete.tpl
            defaultUrl: ""
        }, //文档删除通知
        30: {
            tpl: "Notice_Group_Delete", // /tpl_Notice_Group_Delete.tpl
            defaultUrl: ""
        }, //群组删除通知
        31: {
            tpl: "Notice_Shift2", // /tpl_Notice_Shift2.tpl
            defaultUrl: ""
        }, //转移：线索、客户、机会、个案等通知原负责人
        32: {
            tpl: "Notice_Schedule", // /tpl_Notice_Schedule.tpl
            defaultUrl: ""
        }, //日程
        33: {
            tpl: "Notice_Apply_Not_Remind", // /tpl_Notice_Apply_Not_Remind.tpl
            defaultUrl: ""
        }, //审批通知
        34: {
            tpl: "Notice_Sales_Goal", // /tpl_Notice_Sales_Goal.tpl
            defaultUrl: ""
        }, // 销售目标
        35: {
            tpl: "Notice_Sales_Goal_Del", // /tpl_Notice_Sales_Goal_Del.tpl
            defaultUrl: ""
        }, // 销售目标
        36: {
            tpl: "Notice_Business_Change", // /tpl_Notice_Business_Change.tpl
            defaultUrl: ""
        }, // 各业务变更提醒,点击查看跳转到详细页
        37: {
            tpl: "Notice_Business_Change_Without_User", // /tpl_Notice_Business_Change_Without_User.tpl
            defaultUrl: ""
        }, // 不带发起人的各业务变更提醒，适用于定时任务等
        38: {
            tpl: "Notice_File_Share", //文档分享 // /tpl_Notice_File_Share.tpl
            defaultUrl: ""
        },
        39: {
            tpl: "Notice_Business_Change_Not_Remind", // 各业务变更通知,点击查看跳转到详细页 // /tpl_Notice_Business_Change_Not_Remind.tpl
            defaultUrl: ""
        },
        40: {
            tpl: "Notice_Visit_Plan", //巡访计划 // /tpl_Notice_Visit_Plan.tpl
            defaultUrl: ""
        },
        41: {
            tpl: "Notice_Work_Flow", //工作流通知 // /tpl_Notice_Work_Flow.tpl
            defaultUrl: ""
        },
        42: {
            tpl: "Notice_Report_Export_Log_Not_Remind", //报表导出通知 // /tpl_Notice_Report_Export_Log_Not_Remind.tpl
            defaultUrl: ""
        },
        43: {
            tpl: "Workflow_Remind", //工作流待办通知 // /tpl_Workflow_Remind.tpl
            defaultUrl: ""
        },
        44: {
            tpl: "Workflow_Notice", //工作流提交通知 // /tpl_Workflow_Notice.tpl
            defaultUrl: ""
        }
    };
    userService.getTimeToString = function(time, nowTime, me) {
        nowTime = nowTime - 0;
        time = time - 0;
        var langs = {
            "zh": {
                minutes: "分钟前",
                hours: "小时前",
                monthFormat: "MM月dd日 HH:mm",
                yearFormat: "yyyy年MM月dd日 HH:mm"
            },
            "en": {
                minutes: "minutes ago",
                hours: "hours ago",
                monthFormat: "MM-dd",
                yearFormat: "yyyy-MM-dd"
            }
        };
        var language = window.SESSION.user.language;
        language = language.substring(0, 2).toLowerCase();
        if (language != "zh") {
            language = "en";
        }

        var lang = langs[language];
        var dateString = "";
        var date = new Date(time);
        var nowDate = new Date(nowTime);
        var between = nowTime - time;
        if (date.getFullYear() == nowDate.getFullYear()) {
            if (between < 3600000) { //小于一小时
                if (between < 60000) {
                    between = 60000;
                }
                var dString = (between / 60000) + "";
                if (dString.length > 1) {
                    dString = dString.substring(0, dString.indexOf("."));
                }
                dateString = dString + lang.minutes;
            } else if (between < 86400000) { //小于1天
                var dString = (between / 3600000) + "";
                //dateString = (between / 3600000).toFixed(0) + lang.hours;
                dateString = dString.substring(0, dString.indexOf(".")) + lang.hours;
            } else {
                dateString = lang.monthFormat;
                dateString = dateString.replace("MM", (date.getMonth() + 1) + "");
                dateString = dateString.replace("dd", date.getDate() + "");
                var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours() + "";
                dateString = dateString.replace("HH", hour);
                var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes() + "";
                dateString = dateString.replace("mm", minutes);
            }
        } else {
            dateString = lang.yearFormat;
            dateString = dateString.replace("yyyy", date.getFullYear() + "");
            var month = (date.getMonth() + 1) < 10 ? "0" + date.getMonth() : date.getMonth() + "";
            dateString = dateString.replace("MM", month - 0 + 1);
            var dd = (date.getDate() + 1) < 10 ? "0" + date.getDate() : date.getDate() + "";
            dateString = dateString.replace("dd", dd);
            var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours() + "";
            dateString = dateString.replace("HH", hour);
            var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes() + "";
            dateString = dateString.replace("mm", minutes);
        }
        return dateString;
    };
    userService.notice_hrefType = {
        user: function(hidden, div) {
            var uid = hidden.attr("uid");
            if (div) {
                require.async(["oa/js/colleague/colleagueContentCtrl"], function() {
                    div.colleagueContentCtrl({
                        uid: uid
                    });
                });
            } else {
                return "middle";
            }
        },
        remind: function(hidden, div) {
            var entityId = hidden.attr("eid");
            var remindId = hidden.attr("rid");
            var belongId = hidden.attr("belongId");

            var switchId = hidden.attr("sid");
            //debugger;
            if (belongId != undefined) {
                if (belongId == 1) {
                    switchId = 6;
                } else if (belongId == 3) {
                    switchId = 7;
                } else if (belongId == 35) {
                    switchId = 12;
                } else if (belongId == 64) {
                    switchId = 15;
                } else if (belongId == 15) {
                    switchId = 16;
                }
            }
            var param = {
                entityId: entityId,
                remindId: remindId,
                switchId: switchId
            };
            var remind_hrefTypeJson = {
                //"init-task-list":"",//已废弃
                "init": function(param, div) {
                    //    platform_workreport/detail     "reportId","${entityId}
                    //工作报表组件暂时有问题，找张磊
                    require.async(["oa/js/workreport/workreportContentCtrl"], function() {
                        div.workreportContentCtrl({
                            reportid: entityId,
                            ownerid: window.SESSION.user.id,
                            typeAlias: 'day/month/week'
                        });
                    });
                },
                "to-apply-final": function(param, div) {
                    //approval/to-apply-final"   "applyId","${entityId}"
                    require.async(["oa/js/approval/approvalContentCtrl"], function() {
                        div.approvalContentCtrl({
                            applyId: entityId
                        });
                    });
                },
                "detail_group": function(param, div) {
                    //crm_account", "actionName", "detail","groupId","${entityId}"
                    //window.open("/final/account.action?gid="+entityId);
                },
                "detail_lead": function(param, div) {
                    ///crm_lead", "actionName", "detail","leadId","${entityId}"
                    //window.open("/final/lead.action?id="+entityId);

                },
                "detail_account": function(param, div) {
                    ///crm_account", "actionName", "detail","accountId","${entityId}"})
                    //window.open("/final/account.action?id="+entityId);
                },
                "detail_opportunity": function(param, div) {
                    ///crm_opportunity", "actionName", "detail","opportunityId","${entityId}"})
                    //window.open("/final/opportunity.action?id=" + entityId);
                },
                "detail_cas": function(param, div) {
                    ///crm_case", "actionName", "detail","caseId","${entityId}"}
                    //window.open("/final/case.action?id=" + entityId);
                },
                "detail_task": function(param, div) {
                    ///task", "actionName", "final","taskId","${entityId}","fromPage","6"})
                    require.async(["oa/js/task/taskContentCtrl"], function() {
                        div.taskContentCtrl({
                            taskId: entityId
                        });
                    });
                },
                "detail_schedule": function(param) {
                    ///platform_schedule", "actionName", "final","scheduleId","${entityId}"
                    //暂时还没有 找郭宏
                    if (div) {
                        require.async(["oa/js/schedule/scheduleFinalCtrl"], function() {
                            div.scheduleFinalCtrl({
                                scheduleId: entityId
                            });
                        });
                    }
                },
                "detail_order": function() {
                    ///crm_order", "actionName", "detail","orderId","${entityId}"})
                    //window.open("/final/order.action?id=" + entityId);
                },
                "unchecked_schedules": function() {
                    //"/platform_schedule", "actionName", "unchecked"}) ${entityId}
                    //暂时还没有 找郭宏
                    if (div) {
                        require.async(["oa/js/schedule/scheduleFinalCtrl"], function() {
                            div.scheduleFinalCtrl({
                                scheduleId: entityId
                            });
                        });
                    }
                }
            };
            var crmContentClose = {
                "23": "1",
                "4": "1",
                "5": "1",
                "6": "1",
                "7": "1",
                "8": "1",
                "12": "1",
                "16": "1"
            };
            if (crmContentClose[switchId]) {
                rk.oa.closeContent();
            }
            if (div) {
                if (switchId == "23") {
                    window.open("/customize_detail.action?id=" + entityId + "&belongId=" + belongId);
                } else if (switchId == "4") {
                    window.open("/final/account.action?gid=" + entityId);
                } else if (switchId == "5") {
                    window.open("/final/lead.action?id=" + entityId);
                } else if (switchId == "6") {
                    window.open("/final/account.action?id=" + entityId);
                } else if (switchId == "7") {
                    window.open("/final/opportunity.action?id=" + entityId);
                } else if (switchId == "8") {
                    window.open("/final/case.action?id=" + entityId);
                } else if (switchId == "12") {
                    window.open("/final/order.action?id=" + entityId);
                } else if (switchId == "13") {
                    window.open("/final/agent.action?id=" + entityId);
                } else if (switchId == "14") {
                    window.open("/final/terminal.action?id=" + entityId);
                } else if (switchId == "15") {
                    rk.oa.closeContent();
                    window.open("/final/expenseaccount.action?id=" + entityId);
                } else if (switchId == "16") {
                    window.open("/final/contract.action?id=" + entityId);
                }
                //debugger;
                rk.post("/json/oa_notice/switchAction.action", param, function(json) {
                    if (json.status === 0) {
                        if (remind_hrefTypeJson[json.detailType]) {
                            remind_hrefTypeJson[json.detailType](param, div);
                        }
                    } else {
                        rk.noticeError(rk.i18n('ERROR_SYSTEM'));
                    }
                });
            }
            var popupWidth = {
                //"9":"middle"
            };
            if (popupWidth[switchId]) {
                return popupWidth[switchId];
            } else {
                return null;
            }
        }, //提醒
        detail: function(hidden, div) {
            var $this = this,
                $elem = this.element,
                opt = this.options;
            var systemId = hidden.attr("sid");
            var systemItemId = hidden.attr("siid");
            var detailHrefJson = {
                "501": function() { //动态 message
                    if (div) {
                        require.async(["core/apps/feed/feed"], function() {
                            /*div.mCustomScrollbar({
                             theme: "3d-dark"
                             });*/
                            div.addClass("oa-content-feed-detail");
                            div.feed2015({
                                tabs: [{
                                    tabname: 'none',
                                    url: '/json/sns_feed/one.action?itemId=' + systemItemId + '&systemId=' + systemId
                                }],
                                hasEditor: false
                            });
                        });
                    }
                },
                "502": function() { //文件，判断是否跳转到动态还是文件最终页
                    if (div) {
                        rk.post("/json/oa_notice/detail.action", {
                            systemId: 502,
                            systemItemId: systemItemId
                        }, function(json) {
                            if (json.status === 0) {
                                if (json.data.item.feature && json.data.item.feature == 1) { //分享的文件 跳到动态
                                    require.async(["core/apps/feed/feed"], function() {
                                        div.addClass("oa-content-feed-detail");
                                        /*div.mCustomScrollbar({
                                         theme: "3d-dark"
                                         });*/
                                        div.feed2015({
                                            tabs: [{
                                                tabname: 'none',
                                                url: '/json/sns_feed/one.action?storyId=' + json.data.item.storyId
                                            }],
                                            hasEditor: false
                                        });
                                    });
                                } else if (json.data.item.filetype && json.data.item.filetype == 1) { //图片 跳到动态
                                    require.async(["core/apps/feed/feed"], function() {
                                        div.addClass("oa-content-feed-detail");
                                        /*div.mCustomScrollbar({
                                         theme: "3d-dark"
                                         });*/
                                        div.feed2015({
                                            tabs: [{
                                                tabname: 'none',
                                                url: '/json/sns_feed/one.action?storyId=' + json.data.item.storyId
                                            }],
                                            hasEditor: false
                                        });
                                    });
                                } else {
                                    require.async(['oa/js/rescenter/detail/rescenterDetailCtrl'], function() {
                                        div.fileDetail({
                                            systemId: function() {
                                                return 502
                                            },
                                            systemItemId: function() {
                                                return systemItemId
                                            }
                                        });
                                    });
                                }
                            } else {
                                rk.noticeError(rk.i18n('ERROR_SYSTEM'));
                            }
                        });
                    }
                    return "middle";
                },
                "504": function() { //praise 最终跳到动态  赞扬
                    if (div) {
                        require.async(["core/apps/feed/feed"], function() {
                            div.addClass("oa-content-feed-detail");
                            /*div.mCustomScrollbar({
                             theme: "3d-dark"
                             });*/
                            div.feed2015({
                                tabs: [{
                                    tabname: 'none',
                                    url: '/json/sns_feed/one.action?itemId=' + systemItemId + '&systemId=' + systemId
                                }],
                                hasEditor: false
                            });
                        });
                    }
                },
                "505": function() { //blog 博客
                    if (div) {
                        require.async(["oa/js/blog/blogContentCtrl"], function() {
                            div.blogContentCtrl({
                                bid: systemItemId
                            });
                        });
                    }
                    return "middle";
                },
                /*"611":function(){//sign-in   //废弃

                },*/
                /*"605":function(){//activity-record     activityDetail   //废弃

                },*/
                "607": function() { //activity-record     activityNewDetail
                    if (div) {
                        //rk.oa.closeContent();
                        //window.open("/final/activityrecord.action?id=" + systemItemId);
                        require.async(["core/apps/feed/feed"], function() {
                            div.addClass("oa-content-feed-detail");
                            /*div.mCustomScrollbar({
                             theme: "3d-dark"
                             });*/
                            div.feed2015({
                                tabs: [{
                                    tabname: 'none',
                                    url: '/json/sns_feed/one.action?itemId=' + systemItemId + '&systemId=' + systemId
                                }],
                                hasEditor: false
                            });
                        });
                    }
                },
                "606": function() { //任务
                    if (div) {
                        require.async(["oa/js/task/taskContentCtrl"], function() {
                            div.taskContentCtrl({
                                taskId: systemItemId
                            });
                        });
                    }
                },
                "608": function() { //日程
                    if (div) {
                        require.async(["oa/js/schedule/scheduleFinalCtrl"], function() {
                            div.scheduleFinalCtrl({
                                scheduleId: systemItemId
                            });
                        });
                    }
                },
                "602": function() { //审批
                    if (div) {
                        require.async(["oa/js/approval/approvalContentCtrl"], function() {
                            div.approvalContentCtrl({
                                applyId: systemItemId
                            });
                        });
                    }
                },
                "601": function() { //工作报告
                    if (div) {
                        require.async(["oa/js/workreport/workreportContentCtrl"], function() {
                            div.workreportContentCtrl({
                                reportid: systemItemId,
                                ownerid: window.SESSION.user.id,
                                typeAlias: 'day/month/week'
                            });
                        });
                    }
                },
                "521": function() { //合同
                    if (div) {
                        rk.oa.closeContent();
                        window.open("/final/contract.action?id=" + systemItemId);
                    }
                },
                "525": function() { //报表导出通知
                    if (div) {
                        rk.oa.closeContent();
                        $.getJSON(['/json/crm_report/export-log-detail.action?exportLogId=', systemItemId].join('')).done(function(json) {
                            if (json.status == 0) {
                                var exportLog = json.data.exportLog;
                                if (exportLog.entityName != '') {
                                    exportLog.entityName = rk.i18n('CRM_CORE_EXPORT_REPORT_OPERATION_OVER', ('【' + exportLog.entityName + rk.i18n('REPORT_33') + '】'));
                                } else {
                                    exportLog.entityName = rk.i18n('CRM_CORE_EXPORT_REPORT_OPERATION_OVER', rk.i18n('REPORT_33'));
                                }
                                exportLog.fileLength = parseFloat(exportLog.fileLength / 1024).toFixed(2) + "kb";
                                $this.$dialog = $($.format($.trim(require('oldcrm/tmpl/scrpt_tmpl_container_content_report_export_over.tpl')), exportLog));
                                $this.$dialog.popup({
                                    width: 520,
                                    title: rk.i18n('CRM_CORE_EXPORT_REPORT_OVER'),
                                    actions: {
                                        'closePopUp': function(evt, dialog) {
                                            $this.$dialog && $this.$dialog.popup('close');
                                        }
                                    }
                                });
                            } else {
                                $.msg(rk.i18n('REQUEST_ERROR'));
                            }
                        });
                    }
                }
            };
            if (detailHrefJson[systemId]) {
                var size = detailHrefJson[systemId]();
                if (size) {
                    return size;
                }
            }
        }, //原/t/detail
        depart: function(hidden, div) {
            var gid = hidden.attr("gid");
            require.async(["oa/js/colleague/colleagueDepartContentCtrl"], function() {
                div.groupContentCtrl({
                    gid: gid
                });
            });
        }, //部门详情
        group: function(hidden, div) {
            var gid = hidden.attr("gid");
            if (div) {
                require.async(["oa/js/group/groupContentCtrl"], function() {
                    div.groupContentCtrl({
                        type: "group",
                        gid: gid
                    });
                });
            }
            return "middle";
        }, //群组详情
        task: function(hidden, div) {
            var tid = hidden.attr("tid");
            if (div) {
                require.async(["oa/js/task/taskContentCtrl"], function() {
                    div.taskContentCtrl({
                        taskId: tid
                    });
                });
            }
        }, //任务详情task/final
        visit_plan_notice: function(hidden, div) {
            if (div) {
                //var scheduleService = require('scheduleService');
                rk.oa.closeContent();
                require.async(["scheduleService"], function(scheduleService) {
                    var content = hidden.attr("content");
                    var contentJson = eval("(" + content + ")");
                    var visitStartTime = contentJson.visitStartTime;
                    var showDate = new Date();
                    if (visitStartTime) {
                        showDate = new Date(visitStartTime - 0);
                    }
                    var month = (showDate.getMonth() + 1) < 10 ? "0" + (showDate.getMonth() + 1) : showDate.getMonth() + 1;
                    scheduleService.showFullcalendar("month", showDate.getFullYear() + "-" + month + "-01");
                });
            }
        }, //巡访计划，打开月视图
        crm_contract_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var cid = hidden.attr("cid");
                var gid = hidden.attr("gid");
                if (cid) {
                    window.open("/final/contract.action?id=" + cid);
                } else if (gid) {
                    window.open("/final/contract.action?gid=" + gid);
                }
            }
        }, //原crm_contract/detail
        crm_contact_index: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                window.open("/contract.action");
            }
        },
        crm_contact_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                var cid = hidden.attr("cid");
                if (gid) {
                    window.open("/final/contact.action?gid=" + gid);
                } else if (cid) {
                    window.open("/final/contact.action?id=" + cid);
                }
            }
        },
        crm_account_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var aid = hidden.attr("aid");
                var gid = hidden.attr("gid");
                if (aid) {
                    window.open("/final/account.action?id=" + aid);
                } else if (gid) {
                    window.open("/final/account.action?gid=" + gid);
                }
            }
        }, //远crm_account/detail
        crm_highsea_index: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                window.open("/highsea.action");
            }
        }, //
        crm_opportunity_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var oid = hidden.attr("oid");
                var gid = hidden.attr("gid");
                if (oid) {
                    window.open("/final/opportunity.action?id=" + oid);
                } else if (gid) {
                    window.open("/final/opportunity.action?gid=" + gid);
                }
            }
        },
        crm_lead_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var lid = hidden.attr("lid");
                var gid = hidden.attr("gid");
                if (lid) {
                    window.open("/final/lead.action?id=" + lid);
                } else if (gid) {
                    window.open("/final/lead.action?gid=" + gid);
                }
            }
        },
        crm_account_index: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                window.open("/account.action");
            }
        },
        crm_salesgoal_index: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                window.open("/goal.action");
            }
        },
        crm_case_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var cid = hidden.attr("cid");
                var gid = hidden.attr("gid");
                if (cid) {
                    window.open("/final/case.action?id=" + cid);
                } else if (gid) {
                    window.open("/final/case.action?gid=" + gid);
                }
            }
        },
        crm_customize_detail: function(hidden, div) { //自定义业务实体
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                var cid = hidden.attr("cid");
                var belongId = hidden.attr("belongId");
                if(cid){
                    window.open("/final/customize.action?belongId=" + belongId + "&id=" + cid);
                }
                if(gid) {
                    window.open("/final/customize.action?belongId=" + belongId + "&gid=" + gid);
                }
            }
        },
        crm_product_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                window.open("/final/product.action?gid=" + gid);
            }
        },
        crm_competitor_detail: function(hidden, div) { //竞争对手
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                window.open("/final/competitor.action?gid=" + gid);
            }
        },
        crm_partner_detail: function(hidden, div) { //合作伙伴
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                window.open("/final/partner.action?gid=" + gid);
            }
        },
        crm_campaign_detail: function(hidden, div) { //市场活动
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                window.open("/final/campaign.action?gid=" + gid);
            }
        },
        crm_product_family_detail: function(hidden, div) { //产品线
            rk.oa.closeContent();
        },
        crm_industry_detail: function(hidden, div) { //行业
            rk.oa.closeContent();
        },
        crm_order_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                if (gid) {
                    window.open("/final/order.action?gid=" + gid);
                }
                var oid = hidden.attr("oid");
                if (oid) {
                    window.open("/final/order.action?id=" + oid);
                }
            }
        },
        crm_agent_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                window.open("/final/agent.action?gid=" + gid);
            }
        },
        crm_terminal_detail: function(hidden, div) {
            if (div) {
                rk.oa.closeContent();
                var gid = hidden.attr("gid");
                window.open("/final/terminal.action?gid=" + gid);
            }
        },
        platform_schedule: function(hidden, div) {
                var systemItemId = hidden.attr("scid");
                if (div) {
                    /*require.async(["oa/js/approval/approvalContentCtrl"], function () {
                        div.approvalContentCtrl({
                            scheduleId: systemItemId
                        });
                    });*/
                    require.async(["oa/js/schedule/scheduleFinalCtrl"], function() {
                        div.scheduleFinalCtrl({
                            scheduleId: systemItemId
                        });
                    });
                }
            } //日程
            /*deleteHref:function(hidden,div){
                var text = hidden.attr("text");
                if(div) {
                    require.async(["oa/tmpl/notice/tpl_notice_error.tpl"], function (temp) {
                        var html = rk.templateText(temp, {text: text});
                        div.html(html);
                    });
                }
            }*/
    };
    userService.at_me_hrefType = {

    };
    module.exports = userService;
});
